<template>
  <ex-dialog width="600px" class="ex-diolog" :title="title" :visible="visible" :close-on-click-modal="false"
    @closeDialog="handleClose">
    <div class="main" v-loading="loading"> 
      <p style="margin: 0 10px 14px">订单编号：{{ruleForm.orderNo}}</p>
      <p class="txt">是否确认申请退款</p>
    </div>
    <div class="button_box">
      <el-button type="primary" @click="submitRefund()">确认</el-button>
      <el-button @click="handleClose">取消</el-button>
    </div>
  </ex-dialog>
</template>
<script>
  import Loading from "@/components/Loading/index";
  // api
  import {
    activityOrderRefund,
		orderConfirmRefund,
		refundInfo,
		refundApply,
  } from "@/api/consumeMiningManagement/clockingActivityOrder";

  export default {
    components: {
      Loading,
    },
    props: {
      visible: Boolean,
      id: String,
    },
    data() {
      return {
        labelWidth: '100px',
        inputWidth: '300px',
        title: '退款申请',
        loading: false,
        disabled: false,
				AgreeLoading: false, //按钮loading
				ruleForm: {
					orderNo: '',
					orderId: '',
				},
			
      };
    },
    computed: {},
    created() {
			this.getInfo()
    },
    mounted() {

    },
    methods: {
      //取消
      handleClose(formName) {
        this.$emit("update:visible", false);
      },
      getInfo() { //获取信息
        refundInfo(this.id).then((res) => {
					 this.ruleForm.orderNo = res.result.orderNo
					 this.ruleForm.orderId = res.result.orderId
				})
      },
      submitForm(formName) {
        //创建确定
        this.$refs[formName].validate((valid) => {
          if (valid) {
            refundApply(this.ruleForm.orderId).then((res) => {
							this.$message({
								message: "操作成功",
								type: "success",
							});
							this.ruleForm.orderNo = res.result.orderNo
						})
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
      submitRefund() { //确认退回
        this.AgreeLoading = true
        refundApply(this.ruleForm.orderId).then((res) => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            setTimeout(() => {
              this.$emit('success')
              this.handleClose()
            
              this.AgreeLoading = false
            }, 1000);
          })
          .catch(() => {
            this.AgreeLoading = false;
          });
      },
    },
  };

</script>
<style lang="scss" scoped>
  .ex-diolog {
    ::v-deep .ex--dialog--footer {
      border: none !important;
      padding: 0 !important;
    }

    ::v-deep .ex--dialog--main {
      padding: 10px 20px !important;
    }
  }

  .button_box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
  }
	.txt{
		width: 100%;
		text-align: center;
		margin-top: 40px;
		margin-bottom: 40px;
		font-size: 30px;
		font-weight: bold;
		color: #333;
	}
</style>
